package com.airsystem.pos.bengkel.model.report;

import java.awt.GridBagLayout;
import java.util.Calendar;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;

import net.sf.jasperreports.view.JasperViewer;

import com.airsystem.pos.bengkel.component.DesktopFrame;
import com.airsystem.pos.bengkel.util.DateUtil;

/**
 * @author Budi Oktaviyan <budi.oktaviyan@icloud.com>
 */
public class BillingReportModel extends DesktopFrame {
	protected final int currentMonth;

	protected int currentYear;

	protected GridBagLayout baseLayout = new GridBagLayout();
	protected GridBagLayout panelLayout = new GridBagLayout();

	protected JPanel basePanel = new JPanel();
	protected JPanel buttonPanel = new JPanel();

	protected JLabel periodeLabel = new JLabel();

	protected JComboBox bulanCombo = new JComboBox();
	protected JComboBox tahunCombo = new JComboBox();

	protected JButton printButton = new JButton();

	protected JasperViewer jasperViewer;

	public BillingReportModel() {
		super();

		Calendar calendar = Calendar.getInstance();
		currentMonth = calendar.get(Calendar.MONTH) + 1;

		int currentYear = calendar.get(Calendar.YEAR);
		bulanCombo.addItem("-- PILIH BULAN --");

		for (String item : DateUtil.getMonth()) {
			bulanCombo.addItem(item);
		}

		tahunCombo.addItem("-- PILIH TAHUN --");
		int index = 0;

		for (String item : DateUtil.getYear()) {
			if (item.equals(String.valueOf(currentYear))) {
				this.currentYear = index + 1;
			}
			tahunCombo.addItem(item);

			index++;
		}
	}

	public String getPeriode() {
		StringBuilder periodeBuilder = new StringBuilder(bulanCombo.getSelectedItem().toString());
		periodeBuilder.append("/");
		periodeBuilder.append(tahunCombo.getSelectedItem().toString());

		return periodeBuilder.toString();
	}
}